
using DslModeling = global::Microsoft.VisualStudio.Modeling;
using DslDesign = global::Microsoft.VisualStudio.Modeling.Design;
using DslDiagrams = global::Microsoft.VisualStudio.Modeling.Diagrams;
using Microsoft.VisualStudio.Modeling.Diagrams;
using System.Collections.Generic;

namespace Guava.ChannelTransformations
{
    internal class ClickableImageField : DslDiagrams::ImageField
    {
  public override void OnDoubleClick(DiagramPointEventArgs e)
  {
    base.OnDoubleClick(e);
    
    // Work out which instance was hit.
    NodeShape ConnectorFrom = ((Microsoft.VisualStudio.Modeling.Diagrams.BinaryLinkShapeBase)(e.DiagramHitTestInfo.DiagramClientView.InvokeDragDropTarget)).FromShape;
    NodeShape ConnectorTo = ((Microsoft.VisualStudio.Modeling.Diagrams.BinaryLinkShapeBase)(e.DiagramHitTestInfo.DiagramClientView.InvokeDragDropTarget)).ToShape;
    //ConnectorFrom.GetDomainClass().Name;
      
   // System.Windows.Forms.MessageBox.Show("you clicked on the link from " + ConnectorFrom.Link.SourceElement + " to " + ConnectorTo);
  }

        public override void OnClick(DiagramPointEventArgs e)
        {
            base.OnClick(e);

            // Work out which instance was hit.
            NodeShape ConnectorFrom = ((Microsoft.VisualStudio.Modeling.Diagrams.BinaryLinkShapeBase)(e.DiagramHitTestInfo.DiagramClientView.InvokeDragDropTarget)).FromShape;
            NodeShape ConnectorTo = ((Microsoft.VisualStudio.Modeling.Diagrams.BinaryLinkShapeBase)(e.DiagramHitTestInfo.DiagramClientView.InvokeDragDropTarget)).ToShape;
            //ConnectorFrom.GetDomainClass().Name;

            System.Windows.Forms.MessageBox.Show("you clicked on the link from " + ConnectorFrom.Link.SourceElement + " to " + ConnectorTo);
        }

  public ClickableImageField(string fieldName) : base(fieldName)
  { }
}

    public partial class FlowConnector
    {

        protected override void InitializeDecorators(global::System.Collections.Generic.IList<DslDiagrams::ShapeField> shapeFields, global::System.Collections.Generic.IList<DslDiagrams::Decorator> decorators)
        {
            base.InitializeDecorators(shapeFields, decorators);

            
            List<Decorator> unwanted = new List<Decorator>();
            foreach (Decorator field in decorators)
            {
             if (field.Field.Name == "FromToEnd" )
               unwanted.Add(field);
             }
             foreach (Decorator field in unwanted)
             {
                decorators.Remove(field);
             }
    //create decorator with custom imageField

    //ImageField field2 = new ClickableImageField("FromToEnd");
    //field2.DefaultImage = DslDiagrams::ImageHelper.GetImage(global::Guava.ChannelTransformations.ChannelTransformationsDomainModel.SingletonResourceManager.GetObject("FlowConnectorFromToEndDefaultImage"));
    //DslDiagrams::Decorator decorator1 = new DslDiagrams::ConnectorDecorator(field2, DslDiagrams::ConnectorDecoratorPosition.SourceBottom, DslDiagrams::PointD.Empty);
    //decorators.Add(decorator1);

    }

 }
}
